package top.psjj.mall.utils;

import org.apache.tomcat.util.codec.binary.Base64;
import top.psjj.mall.comment.Constant;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 密码加密
 */
public class MD5Utils {
    public static String getMD5Str(String strValue){
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return Base64.encodeBase64String(md5.digest((strValue+ Constant.System.SALT).getBytes()));
    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
        String result = getMD5Str("123456");
        System.out.println(result);
    }
}